package com.main.common.aspects;


import org.apache.shardingsphere.infra.hint.HintManager;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ForceMasterAspect {
    @Around("@annotation(com.main.common.interfaces.ForceMasterQuery)")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        try (HintManager hintManager = HintManager.getInstance()) {
            hintManager.setWriteRouteOnly();
            return joinPoint.proceed();
        }
    }
}